<template>
  <div>
    <el-page-header icon="" title="企业门户网站管理系统" content="首页" />

    <el-card class="box-card">
      <!-- 24栅格 -->
      <el-row>
        <el-col :span="4">
          <el-avatar :size="100" :src="avatarUrl" />
        </el-col>
        <el-col :span="20">
          <h3 style="line-height: 100px">
            欢迎 {{ store.state.userInfo.username }} 回来, {{ welcomeText }}
          </h3>
        </el-col>
      </el-row>
    </el-card>

    <el-card class="box-card">
      <template #header>
        <div class="card-header">
          <span>公司产品</span>
        </div>
      </template>
      <el-carousel :interval="3000" type="card" height="200px">
        <el-carousel-item v-for="item in 6" :key="item">
          <h3 style="overflow: hidden">{{ item }}</h3>
        </el-carousel-item>
      </el-carousel>
    </el-card>
  </div>
</template>
<script setup>
import { useStore } from "vuex";
import { computed } from "vue";

const store = useStore();

const avatarUrl = computed(
  () =>
    store.state.userInfo.avatar
      ? store.state.API_BASE_URL + store.state.userInfo.avatar //用户上传的头像
      : `https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png` //默认头像
);

const welcomeText = computed(() => {
  return new Date().getHours() < 10 ? "要开心每一天." : "喝杯咖啡提提神吧.";
});
</script>

<style lang="scss" scoped>
.box-card {
  margin-top: 50px;
}

.el-carousel__item h3 {
  color: #475669;
  font-size: 14px;
  opacity: 0.75;
  line-height: 200px;
  margin: 0;
  text-align: center;
}

.el-carousel__item:nth-child(2n) {
  background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n + 1) {
  background-color: #d3dce6;
}
</style>
  